<template>
  <div class="overview">
    <div class="balance-card">
      <div class="balance-label">本月结余</div>
      <div class="balance-amount" :class="monthlyBalance >= 0 ? 'positive' : 'negative'">
        {{ formatMoney(monthlyBalance) }}
      </div>
      <div class="balance-detail">
        <span class="income">收入 {{ formatMoney(monthlyIncome) }}</span>
        <span class="expense">支出 {{ formatMoney(monthlyExpense) }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { formatMoney } from '@/utils/format'

defineProps({
  monthlyIncome: {
    type: Number,
    required: true
  },
  monthlyExpense: {
    type: Number,
    required: true
  },
  monthlyBalance: {
    type: Number,
    required: true
  }
})
</script>

<style scoped>
.overview {
  margin-bottom: 20px;
}

.balance-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.balance-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.balance-amount {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 16px;
}

.balance-amount.positive {
  color: var(--success-color);
}

.balance-amount.negative {
  color: var(--danger-color);
}

.balance-detail {
  display: flex;
  justify-content: space-around;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.balance-detail .income {
  color: var(--success-color);
  font-weight: 600;
}

.balance-detail .expense {
  color: var(--danger-color);
  font-weight: 600;
}

@media (max-width: 640px) {
  .balance-amount {
    font-size: 2rem;
  }
}
</style>
